//
//  main.cpp
//  insertionSort
//
//  Created by Shane on 17/9/21.
//  Copyright © 2017年 Shane. All rights reserved.
//

#include <iostream>


void insertionSort(int a[], int n){
    int i, j, temp;
    for (i = 1; i < n; ++i) {
        temp = a[i];
        for (j = i-1; j >= 0 && temp < a[j]; --j) {
                a[j+1] = a[j];
        }
        a[j+1] = temp;
    }
}

int main(int argc, const char * argv[]) {
    int a[] = {1,3,4,7,5,6,8,9,0,10,2};
    int count = sizeof(a)/sizeof(a[0]);
    insertionSort(a, count);
    return 0;
}
